package com.woniuxy.stage3demo.mapper.kang;

import com.woniuxy.stage3demo.bean.kang.CustomerMsgBean;
import com.woniuxy.stage3demo.pageHelper.PageRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CustomerMsgMapper {

    /**
     * 根据客服id查询
     * @param id
     * @return
     */
    List<CustomerMsgBean> findByCustomerId(@Param("p") PageRequest pageRequest,@Param("custId") int id);

    /**
     * 客服总服务次数
     * @param id
     * @return
     */
    @Select("<script>select count(*) from customer_msg <where> del_flag=0 <if test='cid!=0'> and costomer_id = #{cid}</if></where></script>")
    int countByCustomerId(@Param("cid") int id);

    /**
     * 客服今日服务次数
     * @param id
     * @return
     */
    @Select("<script>select count(*) from customer_msg <where> del_flag=0 and date(start_time) = CURDATE() <if test='cid!=0'> and costomer_id = #{cid}</if></where></script>")
    int countByCustomerDId(@Param("cid") int id);

    /**
     * 客服总服务人数
     * @param id
     * @return
     */
    @Select("<script>select count(distinct user_id) from customer_msg <where> del_flag=0 <if test='cid!=0'> and costomer_id = #{cid} </if></where></script>")
    int countByCUId(int id);

    /**
     * 客服今日服务人数
     * @param id
     * @return
     */
    @Select("<script>select count(distinct user_id) from customer_msg <where> del_flag=0 and date(start_time) = CURDATE() <if test='cid!=0'> and costomer_id = #{cid} </if></where></script>")
    int countByCUDId(int id);


}
